import urllib.request

f = open("/Users/liuyi/Desktop/f5list.txt")             #
line = f.readline()             # 调用文件的 readline()方法
while line:
    print(line, end = '')
    line = f.readline()

    geturl = "https://api-u.f5.com/support/kb-articles/"

    #"?li=false"

    list = (line)

    url = geturl + list

    request = urllib.request.Request(url)

    # 爬取结果
    response = urllib.request.urlopen(request)

    data = response.read()


    # 设置解码方式
    data = data.decode('utf-8')
    print(response.geturl())

    logfile = open('f5bug-database.txt', 'a')      #open(path,'w')：w模式下，写入内容会覆盖掉原来的内容，所以我们还有另一个模式叫做追加模式，就是a模式
    logfile.write(data)
    logfile.close()
#    print(url)
f.close()